import request from "@/utils/request";
const BASE_URL = "wblog_user";
export default {
  /**
   * role列表
   * @param {*} searchMap
   */
  getList() {
    return request({
      url: `${BASE_URL}/role`,
      method: "get"
    });
  },
  /**
   * 通过角色id查询角色信息
   * @param {*} roleId
   */
  getById(roleId) {
    return request({
      url: `${BASE_URL}/role/${roleId}`,
      method: "get"
    });
  },
  /**
   * 修改角色信息
   * @param {*} pojo
   */
  update(pojo) {
    return request({
      url: `${BASE_URL}/role/${pojo.rid}`,
      method: "put",
      data: pojo
    });
  },
  /**
   * 弃用角色
   * @param {*} roleId
   */
  delete(roleId) {
    return request({
      url: `${BASE_URL}/role/qiyong/${roleId}`,
      method: "put"
    });
  },
  /**
   * 给角色添加用户
   * @param {*} rid
   * @param {*} id
   */
  addUser(rid, id) {
    return request({
      url: `${BASE_URL}/role/admin/${rid}/${id}`,
      method: "post"
    });
  },
  /**
   * 给角色添加权限
   * @param {*} rid 角色id
   * @param {*} pid 权限id
   */
  addPermission(rid, pid) {
    return request({
      url: `${BASE_URL}/role/permission/${rid}/${pid}`,
      method: "post"
    });
  },
  /**
   * 添加角色
   * @param {*} pojo
   */
  addRole(pojo) {
    return request({
      url: `${BASE_URL}/role`,
      method: "post",
      data: pojo
    });
  },
  /**
  * 根据角色id查询权限列表
  * @param {*} rid 
  */
  getPermissionListById(rid) {
    return request({
      url: `${BASE_URL}/role/permission/${rid}`,
      method: 'get'
    })
  },
  
  /**
   * 根据角色id和权限id删除角色权限
   * @param {*} rid 角色id
   * @param {*} pid 权限id
   */
  deletePermissionById(rid,pid) {
    return request({
      url: `${BASE_URL}/role/permission/${rid}/${pid}`,
      method: 'delete'
    })
  },
};
